# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=Module-Build-Tiny
pkgname=perl-${_realname}
pkgver=0.039
pkgrel=1
pkgdesc="A tiny replacement for Module::Build"
arch=('any')
url="https://metacpan.org/${_realname}/"
groups=('perl-modules')
license=('PerlArtistic' 'GPL')
depends=('perl' 'perl-ExtUtils-Config' 'perl-ExtUtils-Helpers' 'perl-ExtUtils-InstallPaths')
options=('!emptydirs')
source=("https://www.cpan.org/authors/id/L/LE/LEONT/${_realname}-${pkgver}.tar.gz")
sha256sums=('7d580ff6ace0cbe555bf36b86dc8ea232581530cbeaaea09bccb57b55797f11c')

build() {
  ( export PERL_MM_USE_DEFAULT=1 PERL5LIB=""                 \
      PERL_AUTOINSTALL=--skipdeps                            \
      PERL_MM_OPT="INSTALLDIRS=vendor DESTDIR='$pkgdir'"     \
      PERL_MB_OPT="--installdirs vendor --destdir '$pkgdir'" \
      MODULEBUILDRC=/dev/null

    cd "${srcdir}/${_realname}-${pkgver}"
    /usr/bin/perl Build.PL
    ./Build
  )
}

check() {
  cd "${srcdir}/${_realname}-${pkgver}"
  ( export PERL_MM_USE_DEFAULT=1 PERL5LIB=""
    ./Build test
  )
}

package() {
  cd ${_realname}-${pkgver}
  ( export PERL_AUTOINSTALL=--skipdeps                       \
      PERL_MM_OPT="INSTALLDIRS=vendor DESTDIR='$pkgdir'"     \
      PERL_MB_OPT="--installdirs vendor --destdir '$pkgdir'"
    ./Build install
  )
  find "$pkgdir" -name .packlist -o -name perllocal.pod -delete
}
